<template>
  <el-form :model="formData" :rules="formRules" ref="form" label-width="100px">
    <el-form-item :class="item.class" :label="item.label" :prop="item.key" v-for="item in formList" :key="item.key">
      <el-input
        v-if="!item.itemType || item.itemType === 'input'"
        :type="item.type"
        v-model="item.value"
        :placeholder="item.placeholder"
        :disabled="item.disabled"
        clearable
      ></el-input>
      <el-select 
        v-else-if="item.itemType === 'select'" 
        v-model="item.value" 
        :placeholder="item.placeholder" 
        :disabled="item.disabled"
        clearable
      >
        <el-option
          v-for="c in options"
          :key="c.value"
          :label="c.label"
          :value="c.value">
        </el-option>
      </el-select>
      <el-time-select
        v-else-if="item.itemType === 'time'"
        v-model="item.value"
        :placeholder="item.placeholder"
        :disabled="item.disabled"
        clearable
      >
      </el-time-select>
      <el-switch
        v-else-if="item.itemType === 'switch'"
        v-model="item.value"
        :active-text="item.activeText"
        :inactive-text="item.inactiveText"
      ></el-switch>
      <city-select
        v-else-if="item.itemType === 'city'"
        :local="item.value"
      ></city-select>
      <el-input-number
        v-else-if="item.itemType === 'number'"
        v-model="item.value"
        :min="item.min || 0"
        :max="item.max"
        :label="item.label"
      ></el-input-number>
      <el-date-picker
        v-else-if="item.itemType === 'datePicker'"
        v-model="item.value"
        :type="item.type"
        :placeholder="item.placeholder"
        :disabled="item.disabled"
        :picker-options="item.pickerOptions"
        :range-separator="item.rangeSeparator"
        :start-placeholder="item.startPlaceholder"
        :end-placeholder="item.endPlaceholder"
      >
      </el-date-picker>
      <template v-else-if="item.itemType === 'button'">
        <el-button v-for="b in item.list" :key="b.label" :type="b.type" @click="b.event">{{ b.label }}</el-button>
      </template>
    </el-form-item>
  </el-form>
</template>